package com.woniu.immunologicalmechanism.mapper;

import com.woniu.common.entity.OrderInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ImmuneMapper {

     //通过电话查询核验信息
     @Select("select * from order_info where tel=#{tel}")
     @Results({
             @Result(id = true, column = "id", property = "id"),
             @Result(column = "immune_num", property = "immune_num"),
             @Result(column = "type", property = "type"),
             @Result(column = "vaccine_number", property = "vaccine_number"),
             @Result(column = "immune_date", property = "immune_date"),
             @Result(column = "immune_info", property = "immune_info"),
             @Result(column = "precent_photo", property = "precent_photo"),
             @Result(column = "id", property = "immuneRegister",
                                     many = @Many(select = "com.woniu.immunologicalmechanism.mapper.ImmuneRegisterMapper.selectimmuneRegisterByOid"))
                             })
     List<OrderInfo> selectdogBytel(String tel);

    //通过状态status查询核验信息
    @Select("select * from order_info where status=#{status}")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "immune_num", property = "immune_num"),
            @Result(column = "type", property = "type"),
            @Result(column = "vaccine_number", property = "vaccine_number"),
            @Result(column = "immune_date", property = "immune_date"),
            @Result(column = "immune_info", property = "immune_info"),
            @Result(column = "precent_photo", property = "precent_photo"),
            @Result(column = "id", property = "immuneRegister",
                                   many = @Many(select = "com.woniu.immunologicalmechanism.mapper.ImmuneRegisterMapper.selectimmuneRegisterByOid"))
    })
    List<OrderInfo> selectdogBystatus(int status);
    //通过id查询核验信息
    @Select("select * from order_info where id=#{oid}")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "immune_num", property = "immune_num"),
            @Result(column = "type", property = "type"),
            @Result(column = "vaccine_number", property = "vaccine_number"),
            @Result(column = "immune_date", property = "immune_date"),
            @Result(column = "immune_info", property = "immune_info"),
            @Result(column = "precent_photo", property = "precent_photo"),
            @Result(column = "id", property = "immuneRegister",
                    many = @Many(select = "com.woniu.immunologicalmechanism.mapper.ImmuneRegisterMapper.selectimmuneRegisterByOid"))
    })
    OrderInfo selectdogByoid(int oid);
    //通过uid查询核验信息
    @Select("select * from order_info where uid=#{uid}")
    List<OrderInfo> selectdogByUid(Integer uid);
   //添加犬只核验信息
   @Insert("insert into order_info values(null,#{dname},#{dtype},#{sex},#{weight},#{heigh},#{longs},#{birth},#{dog_card_photo},#{full_face_photo},#{profile_photo},#{tel},#{check_time},#{status},#{uid},null)")
   void insertorderInfo(OrderInfo orderInfo);
    //修改核验信息状态
    @Update("update order_info set status=#{status},cause=#{cause} where id=#{oid}")
    void updateorderInfostatus(@Param("oid") int oid, @Param("status") int status, @Param("cause") String cause);

}
